package hibernate.dao;

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import hibernate.model.object.User;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateTemplate;

import spring.util.Encryption;

public class UserDAOImpl extends BasicDAOImpl implements UserDAO {
	
    public UserDAOImpl() {
        super();
        System.out.println("userDAOImpl create!");
    }

	public String getPassword(Serializable id){
		User user = this.getEntity(User.class, id);
		return user.getPassword();
	}
	public List<User> getUserByEmailAndPwd(String email, String password) throws Exception{
		String whereStr = "where email='"+email+"' and password='"+Encryption.getEncryptStr(password)+"'";
		LinkedHashMap<String, String> orderBy = new LinkedHashMap<String, String>();
		orderBy.put("id", "desc");
		List<User> users = this.getResultList(User.class, whereStr, orderBy);
		return users;
	}
}
